#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int matchPlayersAndTrainers(vector<int>& players, vector<int>& trainers) {
        sort(players.begin(), players.end());
        sort(trainers.begin(), trainers.end());
        int i = 0, j = 0;
        int res = 0;
        for (; i < players.size(); i++)
        {
            while (j < trainers.size() && trainers[j] < players[i])
            {
                j++;
            }
            if (j >= trainers.size())
                break;
            ++j;
        }
        return i;
    }
};